home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / mail / smailsr2.lha / SMail / src / RCS / bsmtp.c,v < prev    next >
Encoding:
Text File  |  1993-11-30  |  20.6 KB  |  1,163 lines

  1. head    2.1;
  2. access;
  3. symbols
  4.     C_2:2.1
  5.     C_1:1.11;
  6. locks; strict;
  7. comment    @ * @;
  8.  
  9.  
  10. 2.1
  11. date    93.11.23.19.58.39;    author Aussem;    state Exp;
  12. branches;
  13. next    1.14;
  14.  
  15. 1.14
  16. date    93.11.23.18.09.08;    author Aussem;    state Exp;
  17. branches;
  18. next    1.13;
  19.  
  20. 1.13
  21. date    93.11.20.23.51.32;    author Aussem;    state Exp;
  22. branches;
  23. next    1.12;
  24.  
  25. 1.12
  26. date    93.11.20.21.32.12;    author Aussem;    state Exp;
  27. branches;
  28. next    1.11;
  29.  
  30. 1.11
  31. date    93.11.14.21.01.46;    author Aussem;    state Exp;
  32. branches;
  33. next    1.10;
  34.  
  35. 1.10
  36. date    93.11.13.22.13.56;    author Aussem;    state Exp;
  37. branches;
  38. next    1.9;
  39.  
  40. 1.9
  41. date    93.11.12.23.09.33;    author Aussem;    state Exp;
  42. branches;
  43. next    1.8;
  44.  
  45. 1.8
  46. date    93.11.09.17.00.22;    author Aussem;    state Exp;
  47. branches;
  48. next    1.7;
  49.  
  50. 1.7
  51. date    93.11.01.23.21.53;    author Aussem;    state Exp;
  52. branches;
  53. next    1.6;
  54.  
  55. 1.6
  56. date    93.10.28.23.31.15;    author Aussem;    state Exp;
  57. branches;
  58. next    1.5;
  59.  
  60. 1.5
  61. date    93.10.28.21.21.08;    author Aussem;    state Exp;
  62. branches;
  63. next    1.4;
  64.  
  65. 1.4
  66. date    93.10.23.22.46.59;    author Aussem;    state Exp;
  67. branches;
  68. next    1.3;
  69.  
  70. 1.3
  71. date    93.10.19.00.36.33;    author Aussem;    state Exp;
  72. branches;
  73. next    1.2;
  74.  
  75. 1.2
  76. date    93.10.17.23.23.47;    author Aussem;    state Exp;
  77. branches;
  78. next    1.1;
  79.  
  80. 1.1
  81. date    93.10.17.21.13.56;    author Aussem;    state Exp;
  82. branches;
  83. next    ;
  84.  
  85.  
  86. desc
  87. @SMTP transport routines
  88. @
  89.  
  90.  
  91. 2.1
  92. log
  93. @Version 2.0 check in
  94. @
  95. text
  96. @/*
  97.  *  bsmtp for smail/rmail
  98.  *
  99.  * This program is free software; you can redistribute it and/or
  100.  * modify it under the terms of the GNU General Public License as
  101.  * published by the Free Software Foundation; either version 2 of
  102.  * the License, or (at your option) any later version.
  103.  *
  104.  * This program is distributed in the hope that it will be useful,
  105.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  106.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  107.  * General Public License for more details.
  108.  *
  109.  * You should have received a copy of the GNU General Public License
  110.  * along with this program; if not, write to the Free Software
  111.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  112.  *
  113.  *
  114.  * $Log: bsmtp.c,v $
  115.  * Revision 1.14  1993/11/23  18:09:08  Aussem
  116.  * the batch/unbatch BSMTP functions moved from main.c
  117.  *
  118.  * Revision 1.13  1993/11/20  23:51:32  Aussem
  119.  * changes output for BSMTP de/batching
  120.  *
  121.  * Revision 1.12  1993/11/20  21:32:12  Aussem
  122.  * extended Debug options
  123.  *
  124.  * Revision 1.11  1993/11/14  21:01:46  Aussem
  125.  * commtents insert
  126.  *
  127.  * Revision 1.10  1993/11/13  22:13:56  Aussem
  128.  * check_site() generates only debug lines if the paramter debug is != No
  129.  * if there is no From line in the BSMTP mail convert_smtp will
  130.  * generate one
  131.  *
  132.  * Revision 1.9  1993/11/12  23:09:33  Aussem
  133.  * check_site does not care about case of the site
  134.  * in BSMTP file
  135.  * cosmetic changes in debug/advise output
  136.  *
  137.  * Revision 1.8  1993/11/09  17:00:22  Aussem
  138.  * cosmetic changes
  139.  *
  140.  * Revision 1.7  1993/11/01  23:21:53  Aussem
  141.  * fmode() call removed
  142.  *
  143.  * Revision 1.6  1993/10/28  23:31:15  Aussem
  144.  * converting \n to \r\n by using fmode() when receiving BSMTP mails
  145.  *
  146.  * Revision 1.5  1993/10/28  21:21:08  Aussem
  147.  * check_bsmtp() security check insert
  148.  *
  149.  * Revision 1.4  1993/10/23  22:46:59  Aussem
  150.  * the file for bsmtp sites is taken from uulib:config
  151.  *
  152.  * Revision 1.3  1993/10/19  00:36:33  Aussem
  153.  * check whether a site is a bsmtp site included
  154.  * hide_dot() implemented
  155.  *
  156.  * Revision 1.2  1993/10/17  23:23:47  Aussem
  157.  * removed the HELO line from write_bsmtp_prolog
  158.  *
  159.  * Revision 1.1  1993/10/17  21:13:56  Aussem
  160.  * Initial revision
  161.  *
  162.  *
  163.  *
  164.  */
  165.  
  166. static char     *rcsid="$Id: bsmtp.c,v 1.14 1993/11/23 18:09:08 Aussem Exp Aussem $";
  167.  
  168. #include <stdio.h>
  169. #include <assert.h>
  170. #include <stdlib.h>
  171. #include <sys/types.h>
  172. #include <sys/stat.h>
  173. #include "defs.h"
  174. #include <ctype.h>
  175.  
  176. extern char hostname[];    /* our host's name         */
  177. extern int debug;
  178. extern char bsmtp_sites[];
  179. extern char nows[];
  180. extern char rmailname[];
  181. extern FILE *mystdin;
  182.  
  183.  
  184. /* Macros for Checking the compress type */
  185. #define CHECK_FREEZE(buf)   ((buf[0]=='0x1f' && buf[1]=='0x9f')?1:0)
  186. #define CHECK_COMPRESS(buf) ((buf[0]=='0x1f' && buf[1]=='0x9d')?1:0)
  187. #define CHECK_GZIP(buf)     ((buf[0]=='0x1f' && buf[1]=='0x8b')?1:0)
  188.  
  189. /*
  190.  * setup_fromline(): generate a RFC conform from line
  191.  *
  192.  * params: address of the sender and the system
  193.  *
  194.  */
  195. static
  196. void
  197. setup_fromline(char *from,char *systemname)
  198. {
  199.     char user[SMLBUF];        /* for rewriting user@@host    */
  200.     char domain[SMLBUF];        /* "   "         "              */
  201.     char addr[SMLBUF];        /* "   "         "              */
  202.     enum eform form;    /* "   "         "              */
  203.     char buf[BIGBUF];
  204.  
  205.    strcpy(addr, from);
  206.     (void) parse(addr, domain, user);
  207.         if(*domain == '\0') {
  208.             form = LOCAL;
  209.         } else {
  210.             form = UUCP;
  211.         }
  212.  
  213.     build(domain, user, form, addr);
  214.  
  215.     (void) strcpy(from, addr);
  216.    setdates();
  217.    sprintf(buf,RFROM(from,nows,systemname));
  218.    strcpy(from,buf);
  219. }
  220.  
  221. /*
  222.  * write_bsmtp_prologue - write the initial SMTP commands for BSMTP transports
  223.  *
  224.  * write out the MAIL FROM line
  225.  *
  226.  */
  227. write_bsmtp_prologue(f,from)
  228.     FILE *f;                /* file to write commands to */
  229.     char *from;
  230. {
  231.     assert(f);
  232.     fprintf(f, "MAIL FROM:<%s!%s>\n",hostname, from);
  233. }
  234.  
  235. /*
  236.  * write_bsmtp_epilogue - write tailing commands for BSMTP transports
  237.  *
  238.  * finish off the data command and write out the QUIT command.
  239.  *
  240.  */
  241. write_bsmtp_epilogue(f)
  242.     FILE *f;
  243. {
  244. assert(f);
  245. fprintf(f, ".\n");
  246. fprintf(f, ".\nQUIT\n");
  247. }
  248.  
  249. /*
  250.  * uncompress_stream()
  251.  *
  252.  * uncompress a stream with cmd <tmp_from_stream >tmp
  253.  * and returns a FILE ptr to the uncompressed file
  254.  *
  255.  */
  256. FILE *uncompress_stream(FILE *fp,char cmd[])
  257. {
  258. char *text;
  259. char tmpfile[SMLBUF],outfile[SMLBUF],line[SMLBUF];
  260. FILE *out;
  261. int rc;
  262. size_t len;
  263.  
  264. if(!fp)
  265.     {
  266.    print_error(FATAL,"uncompress_stream: stream is null '%x'\n",fp);
  267.     return(NULL);
  268.    }
  269.  
  270. fseek(fp,0,SEEK_END);
  271. len=ftell(fp);
  272. if(len==0)
  273.     {
  274.    return(fp);
  275.    }
  276.  
  277. fseek(fp,0,SEEK_SET);
  278. text=malloc(len*sizeof(char));
  279. if(!text)
  280.     {
  281.    print_error(FATAL,"uncompress_stream: no memory for text '%x'\n",text);
  282.    return(NULL);
  283.    }
  284.  
  285. fread(text,len,1,fp);
  286. if(strncmp(text,"HELO ",5)==0)
  287.     {
  288.     print_error(WARNING,"mail not compressed, continue\n");
  289.     fseek(fp,0,SEEK_SET);
  290.     return(fp);
  291.     }
  292.  
  293. print_error(NOTICE,"uncompressing...");
  294.  
  295. strcpy(tmpfile,tmpnam(NULL));
  296. out=fopen(tmpfile,"wb");
  297. if(!out)
  298.     {
  299.    print_error(FATAL,"unable to open tmpfile %s\n",tmpfile);
  300.     return(NULL);
  301.    }
  302. fwrite(text,len,1,out);
  303. fclose(out);
  304. if(text)
  305.     free(text);
  306.  
  307. strcpy(outfile,tmpnam(NULL));
  308. sprintf(line,"%s -d <%s >%s",cmd,tmpfile,outfile);
  309. print_error(NOTICE,"cmd: %s",line);
  310. rc=system(line);
  311. if(rc)
  312.     {
  313.    print_error(FATAL,"uncompressing failed ('%s')\n",line);
  314.     remove(tmpfile);
  315.     remove(outfile);
  316.     return(0);
  317.     }
  318. remove(tmpfile);
  319. return(fopen(outfile,"rb"));
  320. }
  321. /*
  322.  * uncompress_file()
  323.  *
  324.  * uncompress a file with cmd <name >tmp
  325.  * and replace name with the uncompressed
  326.  * file
  327.  */
  328. int uncompress_file(char *name,char cmd[])
  329. {
  330. char outfile[SMLBUF],line[SMLBUF];
  331. int rc;
  332.  
  333. print_error(NOTICE,"uncompressing...");
  334.  
  335. strcpy(outfile,tmpnam(NULL));
  336. sprintf(line,"%s -d <%s >%s",cmd,name,outfile);
  337. print_error(NOTICE,"cmd: %s",line);
  338. rc=system(line);
  339. if(rc)
  340.     {
  341.    print_error(FATAL,"uncompressing failed ('%s')\n",line);
  342.     remove(outfile);
  343.     return(0);
  344.     }
  345.  
  346. sprintf(line,"copy %s %s",outfile,name);
  347. rc=system(line);
  348. remove(outfile);
  349. return(1);
  350. }
  351.  
  352. /*
  353.  * convert_smtp()
  354.  *
  355.  * converts a SMTP mail into UUCP mails and call rmail to
  356.  * deliver them via rmail
  357.  *
  358.  */
  359. convert_smtp(FILE *fp)
  360. {
  361. char line[BIGBUF],cmd[BIGBUF],puf[BIGBUF];
  362. char tmpname[SMLBUF],fromline[SMLBUF],adr[SMLBUF],
  363.      domain[SMLBUF],user[SMLBUF];
  364. char *begin,*end,*result,*systemname;
  365. FILE *out=NULL;
  366. size_t msg,pos;
  367.  
  368. if(!fp)
  369.     return;
  370.  
  371. print_error(NOTICE,"converting BSMTP file...");
  372. strcpy(tmpname,tmpnam(NULL));
  373.  
  374. /* get the first line and check for HELO */
  375. result=fgets(line,sizeof(line),fp);
  376. if(!result)
  377.     goto error;
  378.  
  379. if(strncmp(line,"HELO ",5)!=0)
  380.     {
  381.     print_error(WARNING,"file not in SMTP format aborting !\n");
  382.     return;
  383.     }
  384.  
  385. /* Save the systemname */
  386. end=index(&line[5],'\n');
  387. if(end)
  388.     *end='\0';
  389. systemname=strdup(&line[5]);
  390. print_error(NOTICE,"Receiving mails from '%s'\n",systemname);
  391.  
  392. /* init dates */
  393. setdates();
  394.  
  395. /* Read the first line */
  396. result=fgets(line,sizeof(line),fp);
  397. if(!result)
  398.     goto error;
  399.  
  400. do
  401. {
  402. /* search the MAIL FROM: line */
  403. if(strncmp(line,"MAIL FROM:",10)!=0)
  404.     goto error;
  405. msg=ftell(fp);
  406.  
  407. /* Extracting the sender */
  408. begin=index(line,'<');
  409. end=rindex(line,'>');
  410. if(begin && end)
  411.     {
  412.     *end='\0';
  413.     strcpy(puf,begin+1);
  414.     *end='>';
  415.    }
  416.  
  417. print_error(NOTICE,"From: %s\n",puf);
  418.  
  419. /*  open the tmpfile */
  420. out=fopen(tmpname,"w");
  421. if(!out)
  422.     {
  423.     print_error(FATAL,"unable to open '%s'\n",tmpname);
  424.    goto error;
  425.     }
  426.  
  427. /* remove \n from nows */
  428. strcpy(line,nows);
  429. end=index(line,'\n');
  430. if(end)
  431.     *end='\0';
  432.  
  433. /* setup the fromline */
  434. setup_fromline(puf,systemname);
  435. strcpy(fromline,puf);
  436.  
  437. while((result=fgets(line,sizeof(line),fp))!=NULL)
  438.     if(strncmp(line,"DATA\n",5)==0)break;
  439. if(!result)
  440.     goto error;
  441.  
  442. /* Check whether we have a From user date remote system line */
  443. result=fgets(line,sizeof(line),fp);
  444. /* WE have no From line */
  445. if(strncmp(line,"From ",5)!=NULL)
  446.     {
  447.     fputs(fromline,out);
  448.     if(debug==YES)
  449.         fputs(fromline,stdout);
  450.    }
  451.  
  452. do {
  453.     if(strncmp(line,".\n",5)==0)break;
  454.    /* remove the hidden dots */
  455.     if(strncmp(line,"..\n",5)==0)
  456.         {
  457.         fputs(".\n",out);
  458.         if(debug==YES)
  459.             fputs(".\n",stdout);
  460.       continue;
  461.       }
  462.     fputs(line,out);
  463.     if(debug==YES)
  464.         fputs(line,stdout);
  465.     }while((result=fgets(line,sizeof(line),fp))!=NULL);
  466.  
  467. if(!result)
  468.     goto error;
  469. pos=ftell(fp);
  470.  
  471. fclose(out);
  472.  
  473. fseek(fp,msg,SEEK_SET);
  474. while((result=fgets(line,sizeof(line),fp))!=NULL)
  475.     {
  476.     if(strncmp(line,"DATA\n",5)==0)break;
  477.    begin=index(line,'<');
  478.    if(begin)
  479.        {
  480.        end=rindex(++begin,'>');
  481.        if(end)
  482.            *end='\0';
  483.       strcpy(adr,begin);
  484.       if(islocal(adr, domain, user))
  485.            sprintf(cmd,"%s <%s %s %s",rmailname,tmpname,VFLAG,user);
  486.       else
  487.            sprintf(cmd,"%s <%s %s %s!%s",rmailname,tmpname,VFLAG,domain,user);
  488.       print_error(NOTICE,"cmd: '%s'\n",cmd);
  489.       if(debug != YES)
  490.           system(cmd);
  491.       }
  492.     }
  493.   if(!result)
  494.     goto error;
  495.  
  496. fseek(fp,pos,SEEK_SET);
  497. result=fgets(line,sizeof(line),fp);
  498. if(!result)
  499.     goto error;
  500. }
  501. while(strcmp(line,"QUIT\n")!=0);
  502. remove(tmpname);
  503. return;
  504.  
  505. error:
  506. if(out)fclose(out);
  507. print_error(FATAL,"Corrupt SMTP Format, aborting\n");
  508. remove(tmpname);
  509. }
  510.  
  511. /*
  512.  * check_site()
  513.  *
  514.  * check whether site is in uulib:mail/bsmtp_sites
  515.  *
  516.  */
  517. int check_site(char site[],enum edebug debug)
  518. {
  519. static char *text=NULL;
  520. char puf[SMLBUF]="\n",*found;
  521.  
  522. if(!site ||
  523.    site[0]=='\0')
  524.    return(0);
  525.  
  526. print_error(NOTICE,"BSMTP_check: seaching site '%s' in '%s' ",site,bsmtp_sites);
  527. if(!text)
  528.     {
  529.     FILE *fp=NULL;
  530.     size_t pos;
  531.  
  532.     fp=fopen(bsmtp_sites,"r");
  533.     if(!fp)
  534.         {
  535.         print_error(NOTICE,"check_site: BSMTP file open('%s') failed\n", bsmtp_sites);
  536.         return(0);
  537.       }
  538.     fseek(fp,0,SEEK_END);
  539.     pos=ftell(fp);
  540.     if(pos<1)
  541.         {
  542.         print_error(NOTICE,"check_site: BSMTP file is ('%s') empty\n", bsmtp_sites);
  543.         return(0);
  544.       }
  545.     fseek(fp,0,SEEK_SET);
  546.     text=malloc(pos*sizeof(char));
  547.     if(!text)
  548.         {
  549.         print_error(FATAL,"check_site: unable to alloc %d bytes\n", pos);
  550.         return(0);
  551.       }
  552.     fread(text,pos,1,fp);
  553.     fclose(fp);
  554.     /* case insenstiv please */
  555.     strlwr(text);
  556.     }
  557. strcat(puf,site);
  558. strcat(puf,"\n");
  559. /* case insenstiv please */
  560. strlwr(puf);
  561. if(strstr(text,puf))
  562.     {
  563.     print_error(NOTICE,"found\n");
  564.     return(1);
  565.     }
  566. /* if the file starts with this site there is no \n at the begin */
  567. strcpy(puf,site);
  568. strcat(puf,"\n");
  569. found=strstr(text,puf);
  570. if(found==text)
  571.     {
  572.     print_error(NOTICE,"found\n");
  573.     return(1);
  574.     }
  575.  
  576. print_error(NOTICE,"not found\n");
  577. return(0);
  578. }
  579.  
  580. /*
  581.  * hide_dot()
  582.  *
  583.  * hide a dot behind a double dot
  584.  *
  585.  */
  586. void hide_dot(char *line,size_t max_len)
  587. {
  588. size_t act_len;
  589.  
  590. if(!line || line[0]!='.')
  591.     return;
  592.  
  593. act_len=strlen(line);
  594.  
  595. if(act_len+1<max_len)
  596.     {
  597.    strins(line+1,".");
  598.    }
  599. else
  600.       print_error(FATAL,"hide_dot: unable to hide .dot in line '%s'\n",line);
  601. }
  602.  
  603. /*
  604.  * re_hide_dot()
  605.  *
  606.  * remove the hidden dot
  607.  *
  608.  */
  609. void re_hide_dot(char *line)
  610. {
  611. if(!line || line[0]!='.' || line[1]!='.')
  612.     return;
  613.  
  614. strcpy(&line[0],&line[1]);
  615. }
  616.  
  617.  
  618. int unbatch_smtp(char *spoolfile,char flag)
  619. {
  620.    FILE *fp;
  621.    char *cmd;
  622.  
  623.    if(spoolfile)
  624.    {
  625.           switch(tolower(flag))
  626.           {
  627.           case 'c':
  628.        cmd=get_config("Compress","compress",2);
  629.        if(cmd)
  630.             uncompress_file(spoolfile , cmd);
  631.       else
  632.             uncompress_file(spoolfile , "compress");
  633.         break;
  634.           case 'f':
  635.        cmd=get_config("Freeze","freeze",2);
  636.        if(cmd)
  637.             uncompress_file(spoolfile , cmd);
  638.       else
  639.             uncompress_file(spoolfile , "freeze");
  640.         break;
  641.       }
  642.    fp=fopen(spoolfile,"r");
  643.    convert_smtp(fp);
  644.     }
  645.  
  646.    if(stdin)
  647.    {
  648.           switch(tolower(flag))
  649.           {
  650.           case 'c':
  651.        cmd=get_config("Compress","compress",2);
  652.        if(cmd)
  653.             mystdin=uncompress_stream(stdin , cmd);
  654.             break;
  655.           case 'f':
  656.        cmd=get_config("Freeze","freeze",2);
  657.        if(cmd)
  658.             mystdin=uncompress_stream(stdin , cmd);
  659.         break;
  660.       }
  661.    convert_smtp(mystdin);
  662.    }
  663.  
  664.   if(mystdin==NULL)
  665.       {
  666.       print_error(FATAL,"failed to uncompress stdin in BSMTP mode\n");
  667.       return(10);
  668.       }
  669. return(0);
  670. }
  671.  
  672. int batch_smtp(char compress[],char rsmtp_cmd[])
  673. {
  674.   char batchname[SMLBUF];
  675.   char tmpname[SMLBUF];
  676.   char cmd[SMLBUF];
  677.   int rc;
  678.  
  679.   if(hostname[0]=='\0')
  680.       {
  681.    print_error(FATAL,"No host for batching specified (use -h hostname)\n");
  682.    return(5);
  683.    }
  684.  
  685.   strcpy(batchname,mkfilename(UUBATCH,hostname));
  686.   strcpy(tmpname,mkfilename("T:",hostname));
  687.   rc=access(batchname,R_OK);
  688.   if(rc!=0)
  689.       {
  690.    print_error(NOTICE,"Nothing to queue for %s\n",hostname);
  691.    return(5);
  692.    }
  693.   sprintf(cmd,"%s <%s >%s",compress,batchname,tmpname);
  694.   print_error(NOTICE,"compressing: '%s'\n",cmd);
  695.   rc=system(cmd);
  696.   if(rc)
  697.       {
  698.    print_error(FATAL,"unable to compress batch-file %s ('%s')\n",batchname,cmd);
  699.    return(10);
  700.    }
  701.  
  702.   sprintf(cmd,"%s %s \"%s!%s\"",UUX,tmpname,hostname,rsmtp_cmd);
  703.   print_error(NOTICE,"delivering: '%s'\n",cmd);
  704.   rc=system(cmd);
  705.   if(rc)
  706.       {
  707.    print_error(FATAL,"unable to deliver batch-file %s ('%s')\n",batchname,cmd);
  708.    return(10);
  709.    }
  710.  
  711.   remove(tmpname);
  712.   strcpy(tmpname,batchname);
  713.   strcat(tmpname,".old");
  714.   /* remove old one */
  715.   remove(tmpname);
  716.   /* rename new to old */
  717.   rename(batchname,tmpname);
  718.   /* make sure that uuspool:batch/host is removed */
  719.   remove(batchname);
  720.   return(0);
  721. }
  722. @
  723.  
  724.  
  725. 1.14
  726. log
  727. @the batch/unbatch BSMTP functions moved from main.c
  728. @
  729. text
  730. @d20 3
  731. d71 1
  732. a71 1
  733. static char     *rcsid="$Id: bsmtp.c,v 1.13 1993/11/20 23:51:32 Aussem Exp Aussem $";
  734. @
  735.  
  736.  
  737. 1.13
  738. log
  739. @changes output for BSMTP de/batching
  740. @
  741. text
  742. @d20 3
  743. d68 1
  744. a68 1
  745. static char     *rcsid="$Id: bsmtp.c,v 1.12 1993/11/20 21:32:12 Aussem Exp Aussem $";
  746. d83 1
  747. d263 3
  748. a265 2
  749. char line[BIGBUF],tmpname[SMLBUF],cmd[BIGBUF],puf[BIGBUF],
  750.      fromline[SMLBUF];
  751. d385 5
  752. a389 1
  753.        sprintf(cmd,"%s <%s %s %s",rmailname,tmpname,VFLAG,begin);
  754. d517 106
  755. @
  756.  
  757.  
  758. 1.12
  759. log
  760. @extended Debug options
  761. @
  762. text
  763. @d20 3
  764. d65 1
  765. a65 1
  766. static char     *rcsid="$Id: bsmtp.c,v 1.11 1993/11/14 21:01:46 Aussem Exp Aussem $";
  767. d197 1
  768. a197 1
  769.    print_error(FATAL,"\nunable to open tmpfile %s\n",tmpfile);
  770. d207 1
  771. a207 1
  772. print_error(NOTICE,"\ncmd: %s",line);
  773. d211 1
  774. a211 1
  775.    print_error(FATAL,"\nuncompressing failed ('%s')\n",line);
  776. a216 1
  777. print_error(NOTICE,"\n");
  778. d235 1
  779. a235 1
  780. print_error(NOTICE,"\ncmd: %s",line);
  781. d239 1
  782. a239 1
  783.    print_error(FATAL,"\nuncompressing failed ('%s')\n",line);
  784. a246 2
  785.  
  786. print_error(NOTICE,"\n");
  787. d278 1
  788. a278 1
  789.     print_error(WARNING,"\nfile not in SMTP format aborting !\n");
  790. d287 1
  791. a287 1
  792. print_error(NOTICE,"\nReceiving mails from '%s'\n",systemname);
  793. d314 1
  794. a314 1
  795. print_error(NOTICE,"\nFrom: %s\n",puf);
  796. d320 1
  797. a320 1
  798.     print_error(FATAL,"\nunable to open '%s'\n",tmpname);
  799. d381 1
  800. a381 1
  801.       print_error(NOTICE,"\ncmd: '%s'\n",cmd);
  802. a394 2
  803.  
  804. print_error(NOTICE,"\n");
  805. @
  806.  
  807.  
  808. 1.11
  809. log
  810. @commtents insert
  811. @
  812. text
  813. @d20 3
  814. d62 1
  815. a62 1
  816. static char     *rcsid="$Id: bsmtp.c,v 1.10 1993/11/13 22:13:56 Aussem Exp Aussem $";
  817. d161 1
  818. a161 1
  819.    ADVISE("uncompress_stream: stream is null '%x'\n",fp);
  820. d176 1
  821. a176 1
  822.    ADVISE("uncompress_stream: no memory for text '%x'\n",text);
  823. d183 1
  824. a183 1
  825.     DEBUG("mail not compress, continue\n");
  826. d188 1
  827. a188 1
  828. ADVISE("uncompressing...");
  829. d194 1
  830. a194 1
  831.    DEBUG("\nunable to open tmpfile %s\n",tmpfile);
  832. d204 1
  833. a204 1
  834. DEBUG("\ncmd: %s",line);
  835. d208 1
  836. a208 1
  837.    DEBUG("\nuncompressing failed ('%s')\n",line);
  838. d214 1
  839. a214 1
  840. ADVISE("\n");
  841. d229 1
  842. a229 1
  843. ADVISE("uncompressing...");
  844. d233 1
  845. a233 1
  846. DEBUG("\ncmd: %s",line);
  847. d237 1
  848. a237 1
  849.    DEBUG("\nuncompressing failed ('%s')\n",line);
  850. d246 1
  851. a246 1
  852. ADVISE("\n");
  853. d268 1
  854. a268 1
  855. ADVISE("converting BSMTP file...");
  856. d278 1
  857. a278 1
  858.     DEBUG("\nfile not in SMTP format aborting !\n");
  859. d287 1
  860. a287 1
  861. ADVISE("\nReceiving mails from '%s'\n",systemname);
  862. d314 1
  863. a314 2
  864. if(debug==VERBOSE)
  865.     printf("\nFrom: %s\n",puf);
  866. d320 1
  867. a320 1
  868.     ADVISE("\nunable to open '%s'\n",tmpname);
  869. d381 1
  870. a381 1
  871.       DEBUG("\ncmd: '%s'\n",cmd);
  872. d396 1
  873. a396 1
  874. ADVISE("\n");
  875. d402 1
  876. a402 1
  877. DEBUG("Corrupt SMTP Format, aborting\n");
  878. d421 1
  879. a421 1
  880. ADVISE("BSMTP_check: seaching site '%s' in '%s' ",site,bsmtp_sites);
  881. d430 1
  882. a430 1
  883.         ADVISE("check_site: BSMTP file open('%s') failed\n", bsmtp_sites);
  884. d437 1
  885. a437 1
  886.         ADVISE("check_site: BSMTP file is ('%s') empty\n", bsmtp_sites);
  887. d444 1
  888. a444 1
  889.         ADVISE("check_site: unable to alloc %d bytes\n", pos);
  890. d458 1
  891. a458 1
  892.     ADVISE("found\n");
  893. d467 1
  894. a467 1
  895.     ADVISE("found\n");
  896. d471 1
  897. a471 1
  898. ADVISE("not found\n");
  899. d495 1
  900. a495 1
  901.       DEBUG("hide_dot: unable to hide .dot in line '%s'\n",line);
  902. @
  903.  
  904.  
  905. 1.10
  906. log
  907. @check_site() generates only debug lines if the paramter debug is != No
  908. if there is no From line in the BSMTP mail convert_smtp will
  909. generate one
  910. @
  911. text
  912. @d20 5
  913. d59 1
  914. a59 1
  915. static char     *rcsid="$Id: bsmtp.c,v 1.9 1993/11/12 23:09:33 Aussem Exp Aussem $";
  916. d76 1
  917. d84 2
  918. d116 2
  919. a117 1
  920.  * write out the HELO, MAIL FROM, RCPT TO and DATA commands.
  921. a118 1
  922.  
  923. d131 1
  924. d251 1
  925. a251 1
  926.  * deliver them
  927. a508 1
  928.  
  929. @
  930.  
  931.  
  932. 1.9
  933. log
  934. @check_site does not care about case of the site
  935. in BSMTP file
  936. cosmetic changes in debug/advise output
  937. @
  938. text
  939. @d20 5
  940. d54 1
  941. a54 1
  942. static char     *rcsid="$Id: bsmtp.c,v 1.8 1993/11/09 17:00:22 Aussem Exp Aussem $";
  943. d67 3
  944. d76 30
  945. d247 3
  946. a249 2
  947. char line[BIGBUF],tmpname[SMLBUF],cmd[BIGBUF];
  948. char *begin,*end,*result;
  949. d270 11
  950. a280 1
  951. ADVISE("\nfrom %s",&line[5]);
  952. d290 1
  953. d292 9
  954. a300 1
  955. msg=ftell(fp);
  956. d302 2
  957. a303 4
  958. while((result=fgets(line,sizeof(line),fp))!=NULL)
  959.     if(strncmp(line,"DATA\n",5)==0)break;
  960. if(!result)
  961.     goto error;
  962. d305 1
  963. d310 1
  964. a310 1
  965.     return;
  966. d313 10
  967. d324 8
  968. d333 6
  969. d344 2
  970. d349 4
  971. a352 1
  972.     }
  973. d369 1
  974. a369 1
  975.        sprintf(cmd,"rmail <%s %s %s",tmpname,VFLAG,begin);
  976. d384 1
  977. d401 1
  978. a401 1
  979. int check_site(char site[])
  980. d500 1
  981. @
  982.  
  983.  
  984. 1.8
  985. log
  986. @cosmetic changes
  987. @
  988. text
  989. @d20 3
  990. d49 1
  991. a49 1
  992. static char     *rcsid="$Id: bsmtp.c,v 1.7 1993/11/01 23:21:53 Aussem Exp Aussem $";
  993. d111 1
  994. a111 1
  995.    ADVISE("stream is null '%x'\n",fp);
  996. d126 1
  997. a126 1
  998.    ADVISE("no memory for text '%x'\n",text);
  999. d284 1
  1000. a284 1
  1001.       DEBUG("\nexecute '%s'\n",cmd);
  1002. d332 1
  1003. a332 1
  1004.         ADVISE("BSMTP file open('%s') failed\n", bsmtp_sites);
  1005. d339 1
  1006. a339 1
  1007.         ADVISE("BSMTP file is ('%s') empty\n", bsmtp_sites);
  1008. d346 1
  1009. a346 1
  1010.         ADVISE("unable to alloc %d bytes\n", pos);
  1011. d351 2
  1012. d356 2
  1013. d397 1
  1014. a397 1
  1015.       DEBUG("unable to hide .dot in line '%s'\n",line);
  1016. @
  1017.  
  1018.  
  1019. 1.7
  1020. log
  1021. @fmode() call removed
  1022. @
  1023. text
  1024. @d20 3
  1025. d46 1
  1026. a46 1
  1027. static char     *rcsid="$Id: bsmtp.c,v 1.6 1993/10/28 23:31:15 Aussem Exp Aussem $";
  1028. d108 1
  1029. a108 1
  1030.    ADVISE("stream is zero %x\n",fp);
  1031. d123 1
  1032. a123 1
  1033.    ADVISE("no memory for text %x\n",text);
  1034. d353 1
  1035. a353 1
  1036.     ADVISE("found\n",site);
  1037. d362 1
  1038. a362 1
  1039.     ADVISE("found\n",site);
  1040. d366 1
  1041. a366 1
  1042. ADVISE("not found\n",site);
  1043. @
  1044.  
  1045.  
  1046. 1.6
  1047. log
  1048. @converting \n to \r\n by using fmode() when receiving BSMTP mails
  1049. @
  1050. text
  1051. @d20 3
  1052. d43 1
  1053. a43 1
  1054. static char     *rcsid="$Id: bsmtp.c,v 1.5 1993/10/28 21:21:08 Aussem Exp Aussem $";
  1055. a210 1
  1056. fmode(fp,0);
  1057. d278 1
  1058. a278 1
  1059.       DEBUG("\nexecute '%s'",cmd);
  1060. d283 1
  1061. a283 1
  1062. if(!result)
  1063. @
  1064.  
  1065.  
  1066. 1.5
  1067. log
  1068. @check_bsmtp() security check insert
  1069. @
  1070. text
  1071. @d20 3
  1072. d40 1
  1073. a40 1
  1074. static char     *rcsid="$Id: bsmtp.c,v 1.4 1993/10/23 22:46:59 Aussem Exp Aussem $";
  1075. d208 1
  1076. @
  1077.  
  1078.  
  1079. 1.4
  1080. log
  1081. @the file for bsmtp sites is taken from uulib:config
  1082. @
  1083. text
  1084. @d20 3
  1085. d37 1
  1086. a37 1
  1087. static char     *rcsid="$Id: bsmtp.c,v 1.3 1993/10/19 00:36:33 Aussem Exp Aussem $";
  1088. d306 4
  1089. @
  1090.  
  1091.  
  1092. 1.3
  1093. log
  1094. @check whether a site is a bsmtp site included
  1095. hide_dot() implemented
  1096. @
  1097. text
  1098. @d20 4
  1099. d34 1
  1100. a34 1
  1101. static char     *rcsid="$Id: bsmtp.c,v 1.2 1993/10/17 23:23:47 Aussem Exp Aussem $";
  1102. d46 1
  1103. d296 1
  1104. a296 1
  1105.  * check whether site is in BSMTPSITES
  1106. d304 1
  1107. a304 1
  1108. DEBUG("seaching '%s'",site);
  1109. d310 1
  1110. a310 1
  1111.     fp=fopen(BSMTPSITES,"r");
  1112. d313 1
  1113. a313 1
  1114.         DEBUG("\nBSMTP file open('%s') failed\n", BSMTPSITES);
  1115. d320 1
  1116. a320 1
  1117.         DEBUG("\nBSMTP file is ('%s') empty\n", BSMTPSITES);
  1118. d327 1
  1119. a327 1
  1120.         DEBUG("\nunable to alloc %d bytes\n", pos);
  1121. d337 1
  1122. a337 1
  1123.     DEBUG("found\n",site);
  1124. d346 1
  1125. a346 1
  1126.     DEBUG("found\n",site);
  1127. d350 1
  1128. a350 1
  1129. DEBUG("not found\n",site);
  1130. @
  1131.  
  1132.  
  1133. 1.2
  1134. log
  1135. @removed the HELO line from write_bsmtp_prolog
  1136. @
  1137. text
  1138. @d20 3
  1139. d30 1
  1140. a30 1
  1141. static char     *rcsid="$Id: bsmtp.c,v 1.1 1993/10/17 21:13:56 Aussem Exp Aussem $";
  1142. d286 98
  1143. @
  1144.  
  1145.  
  1146. 1.1
  1147. log
  1148. @Initial revision
  1149. @
  1150. text
  1151. @d19 3
  1152. a21 1
  1153.  * $Log:$
  1154. d24 1
  1155. d27 1
  1156. a27 1
  1157. static char     *rcsid="$Id$";
  1158. a36 1
  1159. extern char hostdomain[];    /* our host's domain         */
  1160. a54 1
  1161.     fprintf(f, "HELO %s\n",hostdomain);
  1162. @
  1163.